# -*- coding: utf-8 -*-
"""
@Time ： 2024/2/6 13:51
@Auth ： gc
"""
import math
from sympy import symbols, Eq, solve

def nsyjs(bj=65000, gtzjlx = 0.035, nlx = 0.02, sxnlx = 0.065,dxjjgpssl = -0.2):
    # 本金
    # bj = 65000

    # 固投债卷利息
    # gtzjlx = 0.035
    gtzj = bj * gtzjlx

    # 底线年利息
    # nlx = 0.02
    # 利息
    lx = bj * nlx
    # 底线基金股票损失率
    # dxjjgpssl = -0.2

    x, y = symbols('x y')
    equation1 = Eq(x + y, bj)
    equation2 = Eq(gtzjlx*x + y*dxjjgpssl, lx)
    solutions = solve((equation1, equation2), (x, y), dict=True)
    answer = solutions[0]

    # 上线年利息
    # sxnlx = 0.065
    gpsxyld = (bj*sxnlx - answer[x]*gtzjlx)/answer[y]
    print(f"""本金:{bj},
    固投债券利息:{round(gtzjlx*100, 1)}%,固投债券盈利{gtzj}
    底线收益:{nlx*100}%,年盈利:{lx}，
    底线投资方案:固投债券{round(answer[x])},基金股票{round(answer[y])},在运行基金股票损失百分之{100*dxjjgpssl}%卖掉基金股票达到底线收益
                当基金股票年收益为{round(gpsxyld*100, 1)}%,达到上线年收益目标{round(sxnlx*100, 1)}%，年收益为{bj*sxnlx}
    """)


if __name__ == '__main__':
    """
    bj:本金，
    gtzjlx：固投债券收益率
    nlx：底线收益率
    sxnlx：上线收益率
    dxjjgpssl：基金股票最大损失率
    """
    nsyjs(bj = 10000, gtzjlx = 0.035, nlx = 0.02, sxnlx = 0.065, dxjjgpssl = -0.2)

